#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <string.h>

int main(int argc, char const *argv[])
{
    char* name = "/tmp/myfifo";
    if(mkfifo(name,0664) != 0 )
    {
        perror("mkfifo");
        exit(EXIT_FAILURE);
    }

    int fid = open(name,O_RDWR);

    if(fid == -1)
    {
        perror("open");
        exit(EXIT_FAILURE);
    }

    char buf[1024];
    int char_nums = 0;
    while((char_nums = read(STDIN_FILENO,buf,1024)) > 0)
    {
        write(fid,buf,char_nums);
    }

    printf("fifo write success\n");
    return 0;
}
